package com.dkm.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class SkipController {

	@RequestMapping("/gologin")
	public void gologin(HttpServletRequest request,HttpServletResponse response) throws IOException {
				
		//完成重定向：到登录页面 
		response.setStatus(302);
		response.setHeader("REDIRECT", "not login");
		response.setHeader("CONTEXTPATH","http://127.0.0.1:8848/crmfront/login.html");
	}
	
	@RequestMapping("/unauthorized")
	public void unauthorized(HttpServletRequest request,HttpServletResponse response) {
		//完成重定向：到无权限页面
		response.setStatus(302);
		response.setHeader("REDIRECT", "unauthorized");
		response.setHeader("CONTEXTPATH","http://127.0.0.1:8848/crmfront/unauthorized.html");
	}
	
	
	@GetMapping("/test")
	@ResponseBody
	public void test() {
		
		System.out.println("test");
	}
	
	@GetMapping("/test1")
	@ResponseBody
	@RequiresPermissions(value = "user:query")
	public void test1() {
		
		System.out.println("test1");
	}
}
